package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏西西
 * Date: 2023-08-31
 * Time: 15:25
 */
public class ThreadDemo17 {
    public static void main(String[] args) throws InterruptedException {
        Object object = new Object();
        Thread t1 = new Thread(() -> {
            System.out.println("wait之前");
            try {
                synchronized (object) {
                    object.wait();
                }

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("wait之后");
        });
        Thread t2 = new Thread(() -> {
            System.out.println("notify之前");
                synchronized (object) {
                    object.notify();
                }
            System.out.println("notify之后");
        });
        t1.start();
        Thread.sleep(500);
        t2.start();

    }
}
